package ru.st.selenium.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;
import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class EditFilmPage extends AnyPage{

	public EditFilmPage(PageManager pages) {
		super(pages);
		
	}

	 @FindBy(name="name")
	  private WebElement nameFilmField;

	  @FindBy(name="year")
	  private WebElement yearFilmField;
	  
	  @FindBy (xpath="//div[@class='maininfo_full']/h2")
	  private WebElement titleFilm;

	  @FindBy(xpath="//div[@class='button']/div/a/img[contains(@src,'/delete.png')]")
	  private WebElement deleteButton;	
	  
	  public void clickDeleteButton() {
			deleteButton.click();
			 wait.until(alertIsPresent()).accept();
		}
	  
	  
	  public String getTitleFilm() {
		    return titleFilm.getText();
		  }
public EditFilmPage ensurePageLoaded() {
		    super.ensurePageLoaded();
		    wait.until(presenceOfElementLocated(By.cssSelector("div.maininfo_full")));
		    return this;
		  }

}
